package LeetCode.interview;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import LeetCode.interview._104_Maximum_Depth_of_Binary_Tree.TreeNode;

import sun.tools.jar.resources.jar;
import util.LogUtils;

/*
 * 
原题　
		Given a positive integer num, write a function which returns True if num is a perfect square else False.
	
	Note: Do not use any built-in library function such as sqrt.
	
	Example 1:
	
	Input: 16
	Returns: True
	
	Example 2:
	
	Input: 14
	Returns: False

题目大意
	判断一个正整数是否是某数的平方
解题思路
	
 * @Date 2017-10-01 11：00
 */
public class _367_Valid_Perfect_Square {
	

    public boolean isPerfectSquare(int num) {
    	if (num <= 0)	return false;
    	for (long i = 1; i <= num; i ++) {
    		if (i*i >  num)	break;
    		if (i*i == num) return true;
    	}
        return false;
    }
    
	public static void main(String[] args) {
		_367_Valid_Perfect_Square obj = new _367_Valid_Perfect_Square();

		LogUtils.println("367", obj.isPerfectSquare(2147483647));
	}

}
